<template>
  <div class="banner">
    <div class="item">
      <img :src="dataList[currentIndex]" />
    </div>
    <div class="page" v-if="this.dataList.length > 1">
      <ul>
        <li @click="gotoPage(prevIndex)">&lt;</li>
        <li
          v-for="(item, index) in dataList"
          @click="gotoPage(index)"
          :class="{ current: currentIndex == index }"
          :key="index"
        >
          {{ index + 1 }}
        </li>
        <li @click="gotoPage(nextIndex)">&gt;</li>
      </ul>
    </div>
    
  </div>
</template>
<style scoped>
* {
  margin: 0;
  padding: 0;
  font-size: 0.16rem;
}
li {
  list-style: none;
  font-size: 0.3rem;
  margin-top: 0.1rem;
}
.tebie li {
  float: left;
  width: 33%;
  overflow: hidden;
  color: #000;
}
.tebie1 li {
  color: #000;
}

li img {
  width: 1rem;
  height: 1rem;
}
p {
  width: 40rem;
}
.te {
  width: 9rem;
  height: 2rem;
}
.xin {
  width: 100%;
  overflow: hidden;
}
span {
  position: absolute;
}
.swiper-container {
  width: 100%;
  height: 100%;
}

.swiper-slide {
  text-align: center;
  font-size: 18px;
  background: #fff;
  height: 200px;
  display: -webkit-box;
  display: -ms-flexbox;
  display: -webkit-flex;
  display: flex;
  -webkit-box-pack: center;
  -ms-flex-pack: center;
  -webkit-justify-content: center;
  justify-content: center;
  -webkit-box-align: center;
  -ms-flex-align: center;
  -webkit-align-items: center;
  align-items: center;
}
ul li {
  list-style: none;
  float: left;
  width: 30px;
  height: 40px;
  line-height: 40px;
  text-align: center;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.8);
  font-size: 14px;
}
.banner {
  max-width: 1200px;
  margin: 0 auto;
  position: relative;
  margin-top: 60px;
}
.banner img {
  width: 100%;
  display: block;
}
.banner .page {
  background: rgba(0, 0, 0, 0.5);
  position: absolute;
  right: 0;
  bottom: 0;
  width: 100%;
}
.banner .page ul {
  float: right;
}
.current {
  color: #ff6700;
}
</style>
<script>
import axios from "axios";
export default {
  props: ["dataList"],
  data() {
    return {

      currentIndex: 0, //默认显示图片
      timer: null, //定时器
      arr: [],
      bool: false,
      n: "",
      arrNew: [],
      srcc: `https://jd.itying.com/`,
      arr1: [],
      m: 0,
    };
  },
  methods: {
    gotoPage(index) {
      this.currentIndex = index;
    },
    //定时器
    runInv() {
      this.timer = setInterval(() => {
        this.gotoPage(this.nextIndex);
      }, 1000);
    },
  },
  computed: {
    swiper() {
      return this.$refs.mySwiper.swiper;
    },
    prevIndex() {
      if (this.currentIndex == 0) {
        return this.dataList.length - 1;
      } else {
        return this.currentIndex - 1;
      }
    },
    //下一张
    nextIndex() {
      if (this.currentIndex == this.dataList.length - 1) {
        return 0;
      } else {
        return this.currentIndex + 1;
      }
    },
  },

};
</script>